package com.yx.robot.sdk.resp;

public class Response<T> {
    public static final int RESULT_SUCCESS = 0;
    public static final int RESULT_ERROR = 1;

    private int resultCode;
    private String message;
    private T data;

    public Response() {

    }

    private Response(Builder<T> builder) {
        setResultCode(builder.resultCode);
        setMessage(builder.message);
        setData(builder.data);
    }

    public static Builder newBuilder() {
        return new Builder();
    }

    public int getResultCode() {
        return resultCode;
    }

    public void setResultCode(int resultCode) {
        this.resultCode = resultCode;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }


    @Override
    public String toString() {
        return "{" +
                " \"message\":" + message +
                '}';
    }


    public static final class Builder<T> {
        private int resultCode;
        private String message;
        private T data;

        private Builder() {
        }

        public Builder resultCode(int resultCode) {
            this.resultCode = resultCode;
            return this;
        }

        public Builder message(String message) {
            this.message = message;
            return this;
        }

        public Builder data(T data) {
            this.data = data;
            return this;
        }

        public Response build() {
            return new Response(this);
        }
    }
}
